home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / lang_asm / softbell / softbell.asm
Encoding:
Assembly Source File  |  1988-03-28  |  3.4 KB  |  93 lines

  1.          page    60,132
  2.          title   SOFTBELL - Routine to soften the bell
  3.          subttl  (C) Copyright 1985,86 by System Enhancement Associates
  4.          page
  5. ;
  6. ;        The normal system bell tone used when a "control G" is printed
  7. ;        is a rather strident tone, suitable for calling one's attention.
  8. ;        However, in many cases one doesn't wish to have one's machine
  9. ;        emitting such loud noises.  In these cases, Softbell can be used
  10. ;        to mute the tone, producing a less obtrusive low buzz.
  11. ;
  12. ;        This will not affect tones produced in other ways.
  13. ;
  14. ;        This program is also a good example of how to write a resident
  15. ;        routine that adds features to an existing system call.
  16. ;
  17.          page
  18.  
  19. code     segment
  20.          assume  cs:code,ds:code,es:code,ss:code
  21.  
  22.          org     100h
  23. soft:    jmp     start               ;system entry point
  24. oldint   equ     $                   ;storage for old interrupt vector
  25. oldoff   dw      ?                   ;old interrupt offset
  26. oldseg   dw      ?                   ;old interrupt segment
  27.  
  28. newint:  sti                         ;routine for new interrupt vector
  29.          cmp     ah,0eh              ;output call?
  30.          jz      usenew              ;yes - see what is being output
  31. useold:  jmp     dword ptr cs:oldint ;no - pass it to BIOS
  32.  
  33. usenew:  cmp     al,7                ;is it a bell?
  34.          jnz     useold              ;no - let BIOS handle it
  35.  
  36.          push    ax                  ;save our registers
  37.          push    bx
  38.          push    cx
  39.  
  40.          mov     bx,30               ;tone duration
  41.          in      al,61h              ;get speaker status
  42.          push    ax                  ;save original status
  43.          sti                         ;this can be interrupted
  44.  
  45. loop1:   and     al,0fch             ;speaker off
  46.          out     61h,al
  47.          mov     cx,2100             ;half tone delay
  48. loop2:   loop    loop2
  49.  
  50.          or      al,2                ;speaker on
  51.          out     61h,al
  52.          mov     cx,2100             ;half tone delay
  53. loop3:   loop    loop3
  54.  
  55.          dec     bx                  ;tone duration
  56.          jnz     loop1
  57.  
  58.          pop     ax                  ;restore speaker status
  59.          out     61h,al
  60.          pop     cx                  ;recover registers
  61.          pop     bx
  62.          pop     ax
  63.          iret                        ;all done here
  64.  
  65. endres   equ     $                   ;end of resident portion
  66.  
  67. banner   db      'SOFTBELL; Version '
  68. TED_VERSION DB '1.04, created on '
  69. TED_DATE DB '02/02/86 at '
  70. TED_TIME DB '01:26:16',13,10
  71.          db      '(C) COPYRIGHT 1985,86 by System Enhancement Associates;'
  72.          db      ' ALL RIGHTS RESERVED',13,10,10
  73.          db      '   Resident portion loaded, Boss!',13,10,'$'
  74.  
  75. start:   mov     ax,3510h            ;read video call vector
  76.          int     21h
  77.          mov     oldoff,bx           ;save offset
  78.          mov     oldseg,es           ;save segment
  79.  
  80.          mov     dx,offset newint    ;get address of new routine
  81.          mov     ax,2510h            ;write video call vector
  82.          int     21h
  83.  
  84.          mov     dx,offset banner    ;point to our greeting
  85.          mov     ah,9                ;print string
  86.          int     21h
  87.  
  88.          mov     dx,offset endres    ;end of resident code
  89.          int     27h                 ;terminate and stay resident
  90.  
  91. code     ends
  92.          end      soft
  93.